package com.onstar.cn.smart.entity;

/**
 * Created by Rengui Lu on 2016/6/29.
 */

//“serviceName”:” charge”,
//        “status”:”1”,
//        "serviceSpec

//"vin": "LSG4567890",
//        "serviceName": "SmartHome",
//        "optStatus":"1"

//"accountID":"1201766702","vin":"LSGKR5WL0G0011C19","serviceName":"smartdevice","optStatus":"1"
//“idpID”:”xxxxxxx”,
//        “accountID”:”xxxxxxxx”,
//        “vin”:”LSGXXXXXXXXXXX”,
//        “serviceName”:”SmartDrive”,
//        “optStatus”:”1”,
//        “availability”:”1”
public class ServiceItem {
    public String idpID;
    public String accountID;
    public String vin;
    public String serviceName;
    public String optStatus;
    public String availability;

    public String getIdpID() {
        return idpID;
    }

    public void setIdpID(String idpID) {
        this.idpID = idpID;
    }

    public String getAccountID() {
        return accountID;
    }

    public void setAccountID(String accountID) {
        this.accountID = accountID;
    }

    public String getVin() {
        return vin;
    }

    public void setVin(String vin) {
        this.vin = vin;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public String getOptStatus() {
        return optStatus;
    }

    public void setOptStatus(String optStatus) {
        this.optStatus = optStatus;
    }

    public void turnOn() {
        setOptStatus("1");
    }

    public void turnOff() {
        setOptStatus("0");
    }

    public String getAvailability() {
        return availability;
    }

    public void setAvailability(String availability) {
        this.availability = availability;
    }


    /**
     * 车辆鉴定报告数据分享协议
     *
     * @param item
     * @return
     */
    public static boolean isCarAssessOpen(ServiceItem item) {
        boolean isOpen = false;
        //车辆鉴定报告数据分享协议 不比较 availability
//        if (isOptAvailable(item)) {// 0: 不可用(隐藏); 1: 可用(展现)
        if (item == null)
            return isOpen;

        if (item.optStatus != null) //  0: 关闭; 1: 开启; 2: 开通中; 3: 失败(客户端显示为关闭)
            if (item.optStatus.equalsIgnoreCase("1")) {
                isOpen = true;
        }
//        }
        return isOpen;
    }
    /**
     * 车辆鉴定报告数据分享协议
     *
     * @param item
     * @return
     */
    public static boolean isOpen(ServiceItem item) {
        boolean isOpen = false;
        //车辆鉴定报告数据分享协议 不比较 availability
//        if (isOptAvailable(item)) {// 0: 不可用(隐藏); 1: 可用(展现)
        if (item == null)
            return isOpen;

        if (item.optStatus != null) //  0: 关闭; 1: 开启; 2: 开通中; 3: 失败(客户端显示为关闭)
            if (item.optStatus.equalsIgnoreCase("1")) {
                isOpen = true;
        }
//        }
        return isOpen;
    }


    /**
     * 车辆鉴定报告数据分享协议
     *
     * @param item
     * @return
     */
    public static boolean isCarAssessClosed(ServiceItem item) {
        boolean isClosed = false;
        if (item == null)
            return isClosed;
        //车辆鉴定报告数据分享协议 不比较 availability
        if (item.optStatus != null)//  0: 关闭; 1: 开启; 2: 开通中; 3: 失败(客户端显示为关闭)
            if (item.optStatus.equalsIgnoreCase("0")) {
                isClosed = true;
            }
        return isClosed;
    }

    public static boolean isClosed(ServiceItem item) {
        boolean isClosed = false;
        if (item == null)
            return isClosed;
        //车辆鉴定报告数据分享协议 不比较 availability
        if (item.optStatus != null)//  0: 关闭; 1: 开启; 2: 开通中; 3: 失败(客户端显示为关闭)
            if (item.optStatus.equalsIgnoreCase("0")) {
                isClosed = true;
            }
        return isClosed;
    }

    /**
     * 车辆鉴定报告数据分享协议
     *
     * @return
     */
    public static boolean isCarAssessInDeveloping(ServiceItem item) {
        boolean isDeveloping = false;
        if (item == null)
            return isDeveloping;
        //车辆鉴定报告数据分享协议 不比较 availability
        if (item.optStatus != null)//  0: 关闭; 1: 开启; 2: 开通中; 3: 失败(客户端显示为关闭)
            if (item.optStatus.equalsIgnoreCase("2")) {
                isDeveloping = true;
            }
        return isDeveloping;
    }

    /**
     * 车辆鉴定报告数据分享协议
     * @param item
     * @return
     */
    public static boolean isCarAssessAvailable(ServiceItem item){
        boolean isAvailable = false;
        //车辆鉴定报告数据分享协议 不比较 availability,
        if (isCarAssessClosed(item) || isCarAssessOpen(item) || isCarAssessInDeveloping(item)) {
            isAvailable = true;
        }
        return isAvailable;
    }

}
